import AmapMercatorTilingScheme from "../crs/AmapMercatorTilingScheme";

export class AmapImageryLayerProvider extends Cesium.UrlTemplateImageryProvider {
  constructor(options = {}) {
    let _url
    switch (options.layer) {
      default:
        _url = options.url
        break
      case 'vec_z':
        _url =
          'https://wprd{s}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=7'
        break
      case 'vec_d':
        _url =
          'https://wprd{s}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=2&style=7'
        break
      case 'img_d':
        _url = 'https://wprd{s}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=2&style=6'
        break
      case 'img_z':
        _url = 'https://wprd{s}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=8'
        break
    }
    options.url = _url
    if (!options.subdomains || !options.subdomains.length) {
      options["subdomains"] = ["01", "02", "03", "04"];
    }
    if (options.crs === "WGS84") {
      options["tilingScheme"] = new AmapMercatorTilingScheme();
    }
    super(options);
  }
}
export default AmapImageryLayerProvider;
